package thread;

import java.util.concurrent.*;

/**
 * @Author Janson
 * @Date 2022/2/24 19:56
 * @Version 1.0
 */
public class TestCallable implements Callable {

    //重写call方法
    @Override
    public Object call() throws Exception {
        System.out.println("执行多线程了：");
        return 1;
    }

    public static void main(String[] args) throws ExecutionException, InterruptedException {
        TestCallable testCallable = new TestCallable();
        //创建线程池对象，用submit 方法启动线程，有返回值
        ExecutorService executorService = Executors.newCachedThreadPool();
        Future submit = executorService.submit(testCallable);
        System.out.println(submit.get());
        executorService.shutdownNow();
    }
}
